<template>
  <div class="app-container">
    <el-form
        inline
        :model="queryParams"
        ref="Powerform"
        label-width="120px"
        size="mini"
      >
        <el-form-item label="" prop="time">
          <el-date-picker
            v-model="queryParams.time"
            type="date"
            placeholder="请选择时间"
            value-format="yyyy-MM-dd"
            :picker-options="pickerOptions"
            clearable
            @change="handleQuery"
          >
          </el-date-picker>
        </el-form-item>
        <el-button type="primary" size="mini" @click="handleQuery"
          >查询</el-button
        >
        <el-button size="mini" type="primary" @click="resetForm('queryParams')"
          >重置</el-button
        >
      </el-form>
    <el-table
      v-loading="loading"
      :data="rainRealDataList"
      class="backtable"
    >
      <el-table-column label="序号" width="80" align="center">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="班次" align="center" prop="ps_class_name" />
      <el-table-column label="时间" align="center" prop="clearTime">
        <template slot-scope="scope">
          <span>{{
            scope.row.date
          }}</span>
        </template>
      </el-table-column>
      
      <el-table-column label="报警详情" align="center" prop="memo" />
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
      class="page"
    />
  </div>
</template>

<script>
import { listRainRealData } from "@/api/realData/tezhong";
import { listMeasurePointStatus } from "@/api/dictData/measurePointStatus";
import "../../../assets/styles/time.css";
export default {
  name: "RainRealData",
  props: {
    parenttime: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 降水量监测实时信息表格数据
      rainRealDataList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 测量时间时间范围
      daterangeClTime: [],
      pickerOptions: {
        disabledDate(time) {
          // return time.getTime() > Date.now();
          const date1 = new Date()
          const date2 = new Date(date1);
          date2.setDate(date1.getDate()-30);  
          if (time.getTime()<= date2.getTime()-8.64e7||time.getTime()>date1.getTime()) {
            return time.getTime()<= date2.getTime()-8.64e7||time.getTime()>date1.getTime(); //时间范围必须是时间戳
          } else {
            return time.getTime() < date2.getTime() - 30 * 8.64e7||time.getTime()>date1.getTime(); //8.64e7就是一天的时间戳 24*60*60*1000 
          }
        },
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        time: null,
      },
      // 表单参数
      form: {},
      //测点状态
      measurePointStatusList: [],
      stime: "",
      etime: ""
    };
  },
  created() {
    if(this.parenttime == '0'){
      this.stime = this.getCurDate() + " " + "00:00:00";
      this.etime = this.getCurDate() + " " + "23:59:59";
      this.daterangeClTime.push(this.stime);
      this.daterangeClTime.push(this.etime);
    }else{
      this.daterangeClTime=[]
    }
    
    this.getList();
  //  listMeasurePointStatus().then(response => {
  //      this.measurePointStatusList = response.rows;
  //   });
  },
  methods: {
    // tableRowClassNameT({ rowIndex }) {
    //   if (rowIndex % 2 == 1) {
    //     return "evencolort";
    //   } else {
    //     return "oddcolort";
    //   }
    // },
    /** 查询降水量监测实时信息列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeClTime && "" != this.daterangeClTime) {
        this.queryParams.params["beginCjTime"] = this.daterangeClTime[0];
        this.queryParams.params["endCjTime"] = this.daterangeClTime[1];
      }
      listRainRealData(this.queryParams).then(response => {
        this.rainRealDataList = response.data.data;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,

        mineCode: null,

        mineName: null,

        cdCode: null,

        clearTime: null,

        clTime: null,

        cjTime: null,

        cdStatus: null,

        cjValue: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetForm() {
      // this.daterangeClTime = [];
      this.queryParams.time = ''
      this.handleQuery();
    },
  }
};
</script>
<style lang="scss" scoped>
::v-deep .el-table--enable-row-hover .el-table__body tr:hover > td {
  background-color: rgba(6, 26, 57, 0.8) !important;
}
</style>
